package com.jugheadzhou.core.zk;

import com.jugheadzhou.core.Base;
import lombok.Getter;
import lombok.Setter;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.AuthInfo;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;


@Getter
@Setter
@ConfigurationProperties(prefix = ZkProperties.PROPERTY_PATH)
public class ZkProperties {
	
	public static final String PROPERTY_PATH = Base.BASE_PROPERTY_PATH + ".zk";
	
	public static final String PROPERTY_PATH_CONNECT = PROPERTY_PATH + ".connectString";
	
	private String serviceName;
	
	private String connectString;

	private int sessionTimeoutMs = 5000;

	private int connectionTimeoutMs = 5000;

	private int baseRetrySleepTimeMs = 1000;
	
	private int maxRetries = 10;

	private String namespace="aegle";

	private boolean needACL = false;

	private List<AuthInfo> authInfos;
	
	public RetryPolicy getRetryPolicy() {
		return new ExponentialBackoffRetry(baseRetrySleepTimeMs, maxRetries);
	}

}
